#include<stdio.h>

int main()
{
    int a[100], b[100];
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    int tmp;
    scanf("%d", &tmp);
    int i = 0;
    int j = 0;
    int find = 1;
    while (j < n)
    {
        if (tmp < a[j] && find)
        {
            find = 0;
            b[i++] = tmp;
        }
        else
        {
            b[i++] = a[j++];
        }
    }
    if (find)
        b[i++] = tmp;
    for (int k = 0; k < i; k++)
        printf("%d ", b[k]);
    return 0;
}